package com.aspose.cells;

final class zaki {
   int a;
   int b;
   long[] c = new long[1];
   long d;
   int e;
   int f;
   int g;
   zakf h;
   private static byte[] i = new byte[]{0, 0, -1, -1};

   int a(zcgb var1) {
      if (var1 != null && var1.k != null) {
         var1.d = var1.h = 0L;
         var1.i = null;
         var1.k.a = var1.k.f != 0 ? 7 : 0;
         var1.k.h.a(var1, (long[])null);
         return 0;
      } else {
         return -2;
      }
   }

   int b(zcgb var1) {
      if (this.h != null) {
         this.h.a(var1);
      }

      this.h = null;
      return 0;
   }

   int a(zcgb var1, int var2) {
      var1.i = null;
      this.h = null;
      this.f = 0;
      if (var2 < 0) {
         var2 = -var2;
         this.f = 1;
      }

      if (var2 >= 8 && var2 <= 15) {
         this.g = var2;
         var1.k.h = new zakf(var1, var1.k.f != 0 ? null : this, 1 << var2);
         this.a(var1);
         return 0;
      } else {
         this.b(var1);
         return -2;
      }
   }

   int b(zcgb var1, int var2) {
      if (var1 != null && var1.k != null && var1.a != null) {
         var2 = var2 == 4 ? -5 : 0;
         int var3 = -5;

         while(true) {
            switch(var1.k.a) {
            case 0:
               if (var1.c == 0) {
                  return var3;
               }

               var3 = var2;
               --var1.c;
               ++var1.d;
               if (((var1.k.b = var1.a[var1.b++]) & 15) != 8) {
                  var1.k.a = 13;
                  var1.i = "unknown compression method";
                  var1.k.e = 5;
                  break;
               } else if ((var1.k.b >> 4) + 8 > var1.k.g) {
                  var1.k.a = 13;
                  var1.i = "invalid window size";
                  var1.k.e = 5;
                  break;
               } else {
                  var1.k.a = 1;
               }
            case 1:
               if (var1.c == 0) {
                  return var3;
               }

               var3 = var2;
               --var1.c;
               ++var1.d;
               int var4 = var1.a[var1.b++] & 255;
               if (((var1.k.b << 8) + var4) % 31 != 0) {
                  var1.k.a = 13;
                  var1.i = "incorrect header check";
                  var1.k.e = 5;
                  break;
               } else if ((var4 & 32) == 0) {
                  var1.k.a = 7;
                  break;
               } else {
                  var1.k.a = 2;
               }
            case 2:
               if (var1.c == 0) {
                  return var3;
               }

               var3 = var2;
               --var1.c;
               ++var1.d;
               var1.k.d = (long)((var1.a[var1.b++] & 255) << 24) & 4278190080L;
               var1.k.a = 3;
            case 3:
               if (var1.c == 0) {
                  return var3;
               }

               var3 = var2;
               --var1.c;
               ++var1.d;
               var1.k.d += (long)((var1.a[var1.b++] & 255) << 16) & 16711680L;
               var1.k.a = 4;
            case 4:
               if (var1.c == 0) {
                  return var3;
               }

               var3 = var2;
               --var1.c;
               ++var1.d;
               var1.k.d += (long)((var1.a[var1.b++] & 255) << 8) & 65280L;
               var1.k.a = 5;
            case 5:
               if (var1.c == 0) {
                  return var3;
               }

               --var1.c;
               ++var1.d;
               var1.k.d += (long)var1.a[var1.b++] & 255L;
               var1.m = var1.k.d;
               var1.k.a = 6;
               return 2;
            case 6:
               var1.k.a = 13;
               var1.i = "need dictionary";
               var1.k.e = 0;
               return -2;
            case 7:
               var3 = var1.k.h.a(var1, var3);
               if (var3 == -3) {
                  var1.k.a = 13;
                  var1.k.e = 0;
                  break;
               } else {
                  if (var3 == 0) {
                     var3 = var2;
                  }

                  if (var3 != 1) {
                     return var3;
                  }

                  var3 = var2;
                  var1.k.h.a(var1, var1.k.c);
                  if (var1.k.f != 0) {
                     var1.k.a = 12;
                     break;
                  } else {
                     var1.k.a = 8;
                  }
               }
            case 8:
               if (var1.c == 0) {
                  return var3;
               }

               var3 = var2;
               --var1.c;
               ++var1.d;
               var1.k.d = (long)((var1.a[var1.b++] & 255) << 24) & 4278190080L;
               var1.k.a = 9;
            case 9:
               if (var1.c == 0) {
                  return var3;
               }

               var3 = var2;
               --var1.c;
               ++var1.d;
               var1.k.d += (long)((var1.a[var1.b++] & 255) << 16) & 16711680L;
               var1.k.a = 10;
            case 10:
               if (var1.c == 0) {
                  return var3;
               }

               var3 = var2;
               --var1.c;
               ++var1.d;
               var1.k.d += (long)((var1.a[var1.b++] & 255) << 8) & 65280L;
               var1.k.a = 11;
            case 11:
               if (var1.c == 0) {
                  return var3;
               }

               var3 = var2;
               --var1.c;
               ++var1.d;
               var1.k.d += (long)var1.a[var1.b++] & 255L;
               if ((int)var1.k.c[0] != (int)var1.k.d) {
                  var1.k.a = 13;
                  var1.i = "incorrect data check";
                  var1.k.e = 5;
                  break;
               } else {
                  var1.k.a = 12;
               }
            case 12:
               return 1;
            case 13:
               return -3;
            default:
               return -2;
            }
         }
      } else {
         return -2;
      }
   }
}
